<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<title>订单明细</title>
<%@ include file="/WEB-INF/component/commonCSS.jsp"%>
<!--[if lt IE 9]>
        <script src="lib/js/html5shiv.min.js"></script>
        <script src="lib/js/respond.min.js"></script>
    <![endif]-->
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
	<input type="hidden" id="typeflag" value='null'>
	<section class="content-header">
	<h1>订单明细</h1>
	<ol class="breadcrumb">
		<li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
		<li class="active">订单明细</li>
	</ol>
	</section>

	<section class="content">
	<div class=" box box-success">
		<div class="box-body">
			<form class=" form-inline" id='form'>
				<div class="form-group form-group-xs">
					订单明细编号： <input class="form-control" type="text" name="orderCode"
						placeholder="订单号" />
				</div>
				<div class="form-group form-group-xs">
					采购日期： <input class="form-control" type="text"  name="submitStartDatetime" id="submitStartDatetime"
						placeholder="yyyy-MM-dd" data-provide="datepicker"
						data-date-fmt="yyyy-MM-dd" />
				</div>
			
				<div class="form-group form-group-xs">
						<label>-</label> <input class="form-control" type="text" name="submitEndDatetime" id ="submitEndDatetime"
						placeholder="yyyy-MM-dd" data-provide="datepicker"
						data-date-fmt="yyyy-MM-dd" />
				</div>
				<div class="form-group form-group-xs">
					药品编码： <input class="form-control" type="text" name="drugCode"
						placeholder="药品编码" />
				</div>
				<div class="form-group form-group-xs">
					通用名： <input class="form-control" type="text" name="drugName"
						placeholder="通用名" />
				</div>

				<div class="form-group form-group-xs">
					配送企业： <input class="form-control" type="text" name="compName"
						placeholder="配送企业" />
				</div>
				<div class="form-group form-group-xs">
					生产企业： <input class="form-control" type="text" name="prodComp"
						placeholder="生产企业" />
				</div>
			<div class="form-group form-group-xs">
                       <label for="txtDrugComp">订单状态：</label>
                       <select class="form-control" name="orderStatus" id = "orderStatus"  style="width: 140px;">
                       </select>
                 </div>
				<button type="button" class="btn btn-success btn-sm" onclick="gridSerch()">查 询</button>
			</form>
		</div>
	</div>
	<table class="jqgrid" id="gridlist"></table>
	<div id="gridpage"></div>
	</section>
	<%@ include file="/WEB-INF/component/commonJS.jsp"%>
	<script type="text/javascript">
		$(function() {
			var date =  new Date();
			var lastDate = date.getFullYear()+","+date.getMonth()+","+date.getDate();
			$('#submitStartDatetime').datepicker( 'setDate',lastDate );
			$('#submitEndDatetime').datepicker( 'setDate' ,date);
			  $("#orderStatus").HNSelect({
		   	        url: "${pageContext.request.contextPath}/selectController/getOrderStatus.html",
		   	        data: { classifyCode: '119' },
		   	        defaultText: "<option value=''>请选择</option>",
		   	    });
			$("#gridlist").jqGrid(
					{   url : "getOrderInfoByHosp.html",
						mtype : "POST",
						datatype : "json",
						autowidth : true,
						shrinkToFit : false,
						height : 255,
						colNames : [ '订单明细编号 ','采购时间 ','采购价 ','采购数量 ','采购金额 ','配送企业 ','确认时间 ','配送时间 ','配送数量 ','配送金额 ','药品编码 ','通用名 ','剂型 ','规格 ','转换系数 ','单位 ','材质 ','生产企业 ','商品编码 ','采购限价 ','是否备案 ','备案类型','订单包号','订单状态'],
						colModel : [{name : 'orderCode',index : 'sdate',width : 100,align : "center",
										formatter:function(cellvalue, options, row){
										 	return "<a href=\"javascript:$.HN.dialog.opendialog('"+row.orderId+"','"+cellvalue+"','${ctx}/purOrderInfo/toOrderLogisticsById.html?orderId="+row.orderId+"','800px','400px',function operResult(val){return operResult;})\">"+cellvalue+"</a>";
			                    		}
									},	
									{name : 'joinPlanTime',index : 'sdate',width : 100,align : "center"}, 
									{name : 'proPrice',index : 'ship',width : 80,align : "right",
			                        	   formatter:function(cellvalue, options, row){
			                                   return formatAmount(cellvalue, options, row);
			                               }},
									{name : 'proCount',index : 'ship',width : 80,align : "center"},
									{name : 'totalPrice',index : 'ship',width : 50,align : "right",summaryType : 'sum'},
									{name : 'compName',index : 'ship',width : 190,align : "center",
										 formatter:function(cellvalue, options,row) {
											 return "<a href=\"javascript:$.HN.dialog.opendialog('"+row.compId+"','"+cellvalue+"','${ctx}/stdCompinfo/toStdCompinfoDetail.html?compId="+row.compId+"','800px','400px',function operResult(val){return operResult;})\">"+cellvalue+"</a>";
							     		}
									},
									{name : 'submitDatetime',index : 'name',width : 150,align : "center"},
									{name : 'delDatetime',index : 'name',width : 150,align : "center"},
									{name : 'delCount',index : 'name',width : 150,align : "center"},
									{name : 'delTotalPrice',index : 'stock',width : 60,align : "center"},
									{name : 'drugCode',index : 'stock',width : 60,align : "center",
										formatter:function(cellvalue, options, row) {
											   return "<a href=\"javascript:$.HN.dialog.opendialog('"+row.drugId+"','"+cellvalue+"','${ctx}/stdDrug/drugInfoDetail.html?drugId="+row.drugId+"','800px','400px',function operResult(val){return operResult;})\">"+cellvalue+"</a>";
									  	}
									}, 
									{name : 'drugName',index : 'drugName',width : 100,align : "center"},
									{name : 'formName',index : 'formName',width : 100,align : "center"},
									{name : 'specName',index : 'specName',width : 100,align : "center"},
									{name : 'factor',index : 'factor',width : 60,align : "center"},
									{name : 'unit',index : 'unit',width : 60,align : "center"}, 
									{name : 'materialName',index : 'materialName',width : 60,align : "center"}, 
									{name : 'prodComp',index : 'prodComp',width : 180,align : "center",
										 formatter:function(cellvalue, options,row) {
											 return "<a href=\"javascript:$.HN.dialog.opendialog('"+row.prodCompId+"','"+cellvalue+"','${ctx}/stdCompinfo/toStdCompinfoDetail.html?compId="+row.prodCompId+"','800px','400px',function operResult(val){return operResult;})\">"+cellvalue+"</a>";
							     		}
									},
									{name : 'goodsCode',index : 'ship',width : 80,align : "center"},
									{name : 'proPriceLimit',index : 'ship',width : 80,align : "center"},
									{name : 'bakDrugFlag',index : 'ship',width : 80,align : "center",
										formatter:function(cellvalue, options, row){
				                            return cellvalue == 1 ? "是" : "否";
				                        }
									},
									{name : 'isLongtimePlan',index : 'ship',width : 80,align : "center",
										formatter:function(cellvalue){
											return cellvalue == 1 ? "长期" : "临时"; 
										}	
									},
									{name : 'orderPackId',index : 'ship',width : 80,align : "center",
										formatter:function(cellvalue, options, row){
										 	return "<a href=\"javascript:$.HN.dialog.opendialog('"+row.orderPackId+"','"+cellvalue+"','${ctx}/purOrderInfo/toOrderLogistics.html?orderPackId="+row.orderPackId+"','800px','400px',function operResult(val){return operResult;})\">"+cellvalue+"</a>";
			                    		}
									},
									{name : 'orderStatus',index : 'ship',width : 80,align : "center"}
						],
						rowNum : 20,
						rowList : [ 10, 20, 30,50,100,500,1000],
						rownumbers : true,
						pager : "#gridpage",
						//multiselect: true, 
						viewrecords : true,
						caption : "订单查询列表",
						jsonReader : {
							repeatitems : false,
							id : "ids"
						}
					});
			$("#gridlist").jqGrid('navGrid', '#gridpage', {add : false,edit : false,del : false,search : false,refresh : false});
			$(window).trigger("resize");
			   $('.btn-success').click(function(){
					   var postJson = formatForm("form");
					   var strat = new Date( postJson['submitStartDatetime'].replace(/-/g,"/") );
					   var End = new Date( postJson['submitEndDatetime'].replace(/-/g,"/") );
					  //起始日期大于截至日期的判断
					   if (strat > End) {
						 var temp =postJson['submitStartDatetime'];
						 postJson['submitStartDatetime'] = postJson['submitEndDatetime'];
						 postJson['submitEndDatetime']= temp;
						 $("[name='submitStartDatetime']").val($("[name='submitEndDatetime']").val());
						 $("[name='submitEndDatetime']").val(temp);
						 temp=null;
					   }
			                $("#gridlist").jqGrid("clearGridData");
			                $("#gridlist").jqGrid('setGridParam',{  
			                mtype: "POST",
			                datatype:'json',
			                postData:postJson,
			                page : 1
			            }).trigger("reloadGrid"); 
			   }); 
		});
	</script>
</body>
</html>